<?xml version="1.0" encoding="utf-8" ?>
<taskrunner name="get.installed.version" version="1.0" date="2008-10-30" maxthreads="1">

  <!-- checks installed version. -->

  <includes>
    <file name="vida.install.settings.xml" />
  </includes>

  

  <tasks>


    <task name="get.installed.version" typename="@SqlServer.ExecuteScalar">
      <description>
        Returns the version from where to attached AccessServer origins.
      </description>
      <dependencies list="start.sqlexpress.service"/>
      <parameters>
        
        <parameter name="connectionstring" value="${accessserver.cs}"/>
        <parameter name="sql" value="select ip.PublicationTitle from serverconsistency sc, installedpublication ip order by ip.changed desc"/>
        <parameter name="throwException" value="false"/>

        <!-- out parameters -->
        <parameter name="output.value" value="installed.version"/>

      </parameters>
    </task>

    <task name="installed.version" typename="@WriteInformation">
      <dependencies list="get.installed.version"/>
      <parameters>
        <parameter name="message" value="Installed version: ¤{installed.version}"/>
      </parameters>
    </task>

    <task name="SetKeepLocalDbTrue" condition="¤{installed.version}=${previous.release} OR ¤{installed.version}=${release}" typename="@SetGlobalProperty">
      <description>
        Sets the global property KeepLocalDb to true if the above condition evaluates to true.
      </description>
      <dependencies list="get.installed.version"/>
      <parameters>
        <parameter name="property.name" value="KeepLocalDb"/>
        <parameter name="property.value" value="true"/>
      </parameters>
    </task>

    <task name="SetKeepLocalDbFalse" condition="¤{installed.version}!=${previous.release} AND ¤{installed.version}!=${release}" typename="@SetGlobalProperty">
      <description>
        Sets the global property KeepLocalDb to true if the above condition evaluates to true.
      </description>
      <dependencies list="get.installed.version"/>
      <parameters>
        <parameter name="property.name" value="KeepLocalDb"/>
        <parameter name="property.value" value="false"/>
      </parameters>
    </task>

    

  </tasks>

</taskrunner>